<script src="/login/status"></script>
<script>
  if (!isLogin) location.href = "login.html";
</script>
<!DOCTYPE html>
<html lang="zh-CN">
  <head>
    <meta charset="utf-8" />
    <title>博文发布 &laquo; 后台</title>
    <link
      rel="stylesheet"
      href="../assets/vendors/bootstrap/css/bootstrap.css"
    />
    <link
      rel="stylesheet"
      href="../assets/vendors/font-awesome/css/font-awesome.css"
    />
    <link rel="stylesheet" href="../assets/vendors/nprogress/nprogress.css" />
    <link rel="stylesheet" href="../assets/css/admin.css" />
    <script src="../assets/vendors/nprogress/nprogress.js"></script>
  </head>

  <body>
    <script>
      NProgress.start();
    </script>

    <div class="main">
      <nav class="navbar">
        <button
          class="classToggle btn btn-default navbar-btn fa fa-bars"
        ></button>
        <ul class="nav navbar-nav navbar-right">
          <li>
            <a href="./addimg.html"><i class="fa fa-th"></i>图片上传</a>
          </li>
          <li>
            <a href="/index.html"><i class="fa fa-th"></i>返回前台</a>
          </li>
          <li>
            <a href="password-reset.html"><i class="fa fa-user"></i>修改密码</a>
          </li>
          <li>
            <a href="login.html"><i class="fa fa-sign-out"></i>退出</a>
          </li>
        </ul>
      </nav>
      <div class="container-fluid">
        <div class="page-title">
          <h1>博文编辑</h1>
        </div>
        <!-- 有错误信息时展示 -->
        <!-- <div class="alert alert-danger">
        <strong>错误！</strong>发生XXX错误
      </div> -->
        <div id="parentBox">
          <form class="row" id="addForm">
            <div class="col-md-9">
              <div class="form-group">
                <label for="title">标题</label>
                <input
                  id="title"
                  class="form-control input-lg"
                  type="text"
                  placeholder="文章标题"
                  name="title"
                />
              </div>
              <div class="form-group">
                <label for="contentOf">内容</label>
                <textarea
                  id="content"
                  class="form-control input-lg"
                  cols="30"
                  rows="10"
                  placeholder="内容"
                  name="content"
                  style="display: none"
                ></textarea>
                <div id="content1"></div>
              </div>
            </div>
            <div class="col-md-3">
              <div class="form-group">
                <label for="feature">博文封面</label>
                <!-- show when image chose -->
                <img class="help-block thumbnail" style="display: none" />
                <input id="feature" class="form-control" type="file" />
                <input type="hidden" name="thumbnail" id="thumbnall" />
              </div>
              <div class="form-group">
                <label for="category">所属分类</label>
                <select
                  id="category"
                  class="form-control"
                  name="category"
                ></select>
              </div>
              <div class="form-group">
                <label for="created">发布时间</label>
                <input
                  id="created"
                  class="form-control"
                  type="date"
                  name="createAt"
                />
              </div>
              <div class="form-group">
                <label for="status">状态</label>
                <select id="status" class="form-control" name="state">
                  <option value="0">草稿</option>
                  <option value="1">已发布</option>
                </select>
              </div>
              <div class="form-group">
                <button class="btn btn-primary" type="submit">添加</button>
              </div>
            </div>
          </form>
        </div>
      </div>
    </div>

    <div class="aside">
      <div class="profile">
        <img class="avatar" src="" />
        <h3 class="name">Coder</h3>
      </div>
      <ul class="nav">
        <li>
          <a href="index.html"><i class="fa fa-dashboard"></i>仪表盘</a>
        </li>
        <li class="active">
          <a href="#menu-posts" data-toggle="collapse">
            <i class="fa fa-thumb-tack"></i>博文管理<i
              class="fa fa-angle-right"
            ></i>
          </a>
          <ul id="menu-posts" class="collapse in">
            <li><a href="posts.html">所有博文</a></li>
            <li class="active"><a href="post-add.html">新增博文</a></li>
            <li><a href="categories.html">分类目录</a></li>
          </ul>
        </li>
        <li>
          <a href="comments.html"><i class="fa fa-comments"></i>评论列表</a>
        </li>
        <li>
          <a href="users.html"><i class="fa fa-users"></i>用户管理</a>
        </li>
        <li>
          <a href="#menu-settings" class="collapsed" data-toggle="collapse">
            <i class="fa fa-cogs"></i>设置选项<i class="fa fa-angle-right"></i>
          </a>
          <ul id="menu-settings" class="collapse">
            <li><a href="slides.html">图片轮播</a></li>
            <li><a href="settings.html">博客设置</a></li>
          </ul>
        </li>
      </ul>
    </div>
    <script src="../assets/vendors/wangEditor/wangEditor.min.js"></script>
    <script src="../assets/vendors/jquery/jquery.js"></script>
    <script src="../assets/vendors/bootstrap/js/bootstrap.js"></script>
    <script src="../assets/vendors/art-template/template-web.js"></script>
    <script src="../assets/js/common.js"></script>
    <script>
      const E = window.wangEditor;
      const editor = new E("#content1");
      editor.config.height = 500;
      // 或者 const editor = new E( document.getElementById('div1') )
      editor.create();
      window.editor = editor;
      editor.config.uploadImgServer = "/posts/";
    </script>
    <script>
      NProgress.done();
    </script>
    <!-- 文章分类下拉框模板 -->
    <script type="text/html" id="categoryTpl">
      {{each data}}
      <option value="{{$value._id}}">{{$value.title}}</option>
      {{/each}}
    </script>
    <!-- 修改文章信息表单模板 -->
    <script type="text/html" id="modifyTpl">
      <form class="row" id="modifyForm" data-id="{{_id}}">
          <div class="col-md-9">
              <div class="form-group">
                  <label for="title">标题</label>
                  <input id="title" class="form-control input-lg" type="text" placeholder="文章标题" name="title" value="{{title.trim()}}">
              </div>
                     <div class="form-group">
                <label for="contentOf">内容</label>
                <textarea id="content" class="form-control input-lg" cols="30" rows="10" placeholder="内容" name="content" style="display: none;"></textarea>
                <div id="content1"></div>
              </div>
          </div>
          <div class="col-md-3">
              <div class="form-group">
                  <label for="feature">文章封面</label>
                  <!-- show when image chose -->
                  <img class="help-block thumbnail" style="display: none">
                  <input id="feature" class="form-control" type="file">
                  <input type="hidden" name="thumbnail" id="thumbnall" value="{{thumbnail}}">
              </div>
              <div class="form-group">
                  <label for="category">所属分类</label>
                  <select id="category" class="form-control" name="category">
                      {{each categories}}
                          <option {{category._id == $value._id ? 'selected' : '' }}  value="{{$value._id}}">{{$value.title}}</option>
                      {{/each}}
      </select>
              </div>
              <div class="form-group">
                  <label for="created">发布时间</label>
                  <input id="created" class="form-control" type="date" name="createAt" value="{{null}}">
              </div>
              <div class="form-group">
                  <label for="status">状态</label>
                  <select id="status" class="form-control" name="state">
        <option value="0" {{state == 0 ? 'selected' : '' }}>草稿</option>
        <option value="1" {{state == 1 ? 'selected' : '' }}>已发布</option>
      </select>
              </div>
              <div class="form-group">
                  <button class="btn btn-primary" type="submit">修改</button>
              </div>
          </div>
      </form>
    </script>
    <script src="../assets/js/post-add.js"></script>
  </body>
</html>
